package com.yc.common.exceptions.captcha;

import com.yc.common.constant.HttpStatus;
import com.yc.common.enums.CaptchaType;
import com.yc.common.exceptions.ServiceException;
import lombok.Getter;
import lombok.Setter;

/**
 * 验证码失效异常类
 *
 * @author ruoyi---yanchen
 */
@Getter
@Setter
public class CaptchaExpireException extends ServiceException {
    private static final long serialVersionUID = 1L;

    /**
     * 验证码类型
     */
    private CaptchaType captchaType;

    /**
     * 过期时间 (毫秒)
     */
    private Long expireTime;

    /**
     * 创建时间 (毫秒)
     */
    private Long createTime;

    /**
     * 错误代码
     */
    private String errorCode;

    /**
     * 默认构造函数
     */
    public CaptchaExpireException() {
        super("验证码已失效，请重新获取", HttpStatus.BAD_REQUEST);
        this.captchaType = CaptchaType.IMAGE;
        this.errorCode = "CAPTCHA_EXPIRED";
    }

    /**
     * 使用自定义消息构造
     *
     * @param message 错误消息
     */
    public CaptchaExpireException(String message) {
        super(message, HttpStatus.BAD_REQUEST);
        this.captchaType = CaptchaType.IMAGE;
        this.errorCode = "CAPTCHA_EXPIRED";
    }

    /**
     * 完整构造函数
     *
     * @param message     错误消息
     * @param captchaType 验证码类型
     * @param createTime  创建时间
     * @param expireTime  过期时间
     */
    public CaptchaExpireException(String message, CaptchaType captchaType,
                                  Long createTime, Long expireTime) {
        super(message, HttpStatus.BAD_REQUEST);
        this.captchaType = captchaType;
        this.createTime = createTime;
        this.expireTime = expireTime;
        this.errorCode = "CAPTCHA_EXPIRED";
    }

    /**
     * 带错误代码的构造函数
     *
     * @param message   错误消息
     * @param errorCode 错误代码
     */
    public CaptchaExpireException(String message, String errorCode) {
        super(message, HttpStatus.BAD_REQUEST);
        this.captchaType = CaptchaType.IMAGE;
        this.errorCode = errorCode;
    }
}